#include <iostream>

class BaseException
{
public:
    virtual void ErrorString() = 0;
};

class NullptrException:public BaseException
{
public:
    void ErrorString()
    {
        std::cout<<"空指针异常!\n";
    }
};

class Divide0Exception:public BaseException
{
public:
    void ErrorString()
    {
        std::cout<<"除0异常!\n";
    }
};

void func()
{
    throw Divide0Exception();
}

int main()
{
    try
    {
        func();
    }
    catch(BaseException& e)
    {
        e.ErrorString();
    }
    
    return 0;
}